#include<iostream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
bool CheckString(string src);
int main()
{
	string a;
	cin>>a;
	if(CheckString(a)==true)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}
bool CheckString(string src)
{
	stack<char>vc;
	for(int i=0;i<(int)src.size();i++)
	{
		
		if(src[i]==')'&&vc.size()!=0&&vc.top()=='(')
		{
			vc.pop();
		}
		else if(src[i]==')'&&vc.size()!=0&&vc.top()!='(')
		{
			vc.push(src[i]);
		}
		else if(src[i]==']'&&vc.size()!=0&&vc.top()=='[')
		{
			vc.pop();
		}
		else if(src[i]==']'&&vc.size()!=0&&vc.top()!='[')
		{
			vc.push(src[i]);
		}
		else if(src[i]=='('||src[i]=='[')
		{
			vc.push(src[i]);
		}
		else if(src[i]==')'&&vc.size()==0)
		{
			vc.push(src[i]);
		}
		else if(src[i]==']'&&vc.size()==0)
		{
			vc.push(src[i]);
		}
	}
	if(vc.size()==0)
	{
		return true;
	}
	else
	{
		return false;
	}
	
}

